<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div>
    <input type="text"  v-model="num1"><br>
    <input type="text"  v-model="num2"><br>
    <input type="button" value="加" onclick="f(1)" @click="f('+')">
    <input type="button" value="减" onclick="f(2)" @click="f('-')">
    <input type="button" value="乘" onclick="f(3)" @click="f('*')">
    <input type="button" value="除" onclick="f(4)" @click="f('/')">
</div>
<h1>结果:{{result}}</h1>

<script src="../js/vue.js"></script>
<script>
    let v = new Vue({
        el:"div",
        data:{
            num1:"",num2:"",result:""
        },
        methods:{
            f(x){
                /*eval()方法可以将字符串以代码的形式执行*/
                v.result = eval(v.num1+x+v.num2);
            }
        }
    })
</script>
</body>
</html>